
var app = require('express')();
var server = require('http').createServer(app);
var io = require('socket.io').listen(server);

server.listen(8080,function(err){
        if(err){
            console.error('bind 8080 err');
        }else{
            console.info('server has binded with port 8080 ')
        }
    });

app.get('/', function (req, res) {
    res.sendFile(__dirname + '/client/index.html');
});

io.sockets.on('connection', function (socket) {
    console.log('socketio connection.');
    socket.emit('news', { hello: 'world' });
    socket.on('my other event', function (data) {
        console.log(data);
    });
});